home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / TSR.SWG / 0013_Dealing with TSR's.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  1KB  |  47 lines

  1. (*
  2. LOU DUCHEZ
  3.  
  4. >I need to write a TSR, but the books I have really don't go into much detail
  5. >about them.  Anyone know any good books that explain about them?
  6.  
  7. My recommendation:
  8.  
  9. "Turbo Pascal 6.0: The Complete Reference" by Stephen O'Brien
  10.  
  11. Taught me about TSRs.  The basic deal with a TSR is these things:
  12.  
  13. 1)  A $M directive to reduce the amount of memory used.
  14. 2)  A "Keep" procedure to make it TSR.
  15. 3)  (the tricky part) A new interrupt handler.  Actually it's not so tricky.
  16.     What your handler should do is react to the hardware, then call the old
  17.     interrupt handler.  In parts here:
  18.  
  19.     A)  Determine old handler address with getintvec.  Assign it to a
  20.         "procedure" variable like so:
  21.  
  22.         var oldkbdhandler: procedure;   { for a keyboard handler }
  23.  
  24.         getintvec($09, @oldkbdhandler);
  25.  
  26.  
  27.     B)  Create a new handler that reads the hardware: like so:
  28.  
  29.         var port60h: byte;              { global variable }
  30.  
  31.  
  32.         procedure newkeyboardhandler; interrupt;
  33.         begin
  34.           port60h := port[$60];  { store keyboard port status }
  35.           asm
  36.             pushf     { PUSHF instruction is crucial before calling old ISR }
  37.             end;
  38.           oldkbdhandler;    { run the old keyboard handler }
  39.           end;
  40.  
  41.  
  42.     C)  To hook up the new handler, it's:
  43.  
  44.         setintvec($09, @newkeyboardhandler);
  45.  
  46. *)
  47.